package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.entity.VoucherOrder;
import com.hmdp.service.IVoucherOrderService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("/voucher-order")
public class VoucherOrderController {

    @Resource
    private IVoucherOrderService iVoucherOrderService;

    /**
     * 优惠券抢购
     * @author Yhans
     * @date 2024/2/22 18:55
     */
    @PostMapping("/{id}")
    public Result Voucher(@PathVariable("id") Long voucherId) {
        return iVoucherOrderService.voucher(voucherId);
    }

    /**
     * 优惠券限时抢购
     * @author Yhans
     * @date 2024/2/22 17:31
     */
    @PostMapping("seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId) throws InterruptedException {
        return iVoucherOrderService.seckillVoucher2(voucherId);
    }
}
